using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

/// <summary>
/// Summary description for ManageBook
/// </summary>
public class ManageBook
{

    public void enterBook(Book book) { }
    public void deleteBook(String Barcode) { }
    public SqlDataAdapter SearchByTitle(String Title)
    {
        DatabaseAccess accessor = new DatabaseAccess();

        return accessor.SearchForBook(Book.TITLE_CODE, Title); 
    }
    public SqlDataAdapter SearchByAuthor(String Author)
    {
        DatabaseAccess accessor = new DatabaseAccess();

        return accessor.SearchForBook(Book.AUTHOR_CODE, Author); 
    }
    public SqlDataAdapter SearchBySubject(String Subject)
    {
        DatabaseAccess accessor = new DatabaseAccess();

        return accessor.SearchForBook(Book.SUBJECT_CODE, Subject); 
    }
    public SqlDataAdapter SearchByKeyword(String Keyword)
    {
        DatabaseAccess accessor = new DatabaseAccess();

        return accessor.SearchForBook(Book.KEYWORDS_CODE, Keyword); 
    }
    public SqlDataAdapter SearchByBarcode(String Barcode)
    {
        DatabaseAccess accessor = new DatabaseAccess();

        return accessor.SearchForBook(Book.BARCODE_CODE, Barcode); ;
    }
    public SqlDataAdapter SearchByISBN(String ISBN)
    {
        DatabaseAccess accessor = new DatabaseAccess();

        return accessor.SearchForBook(Book.ISBN_CODE, ISBN) ;
    }

    //search by barcode, title, author, or callNumber
    //for Librarian Manage Book - Jacquie
    public SqlDataAdapter LibrarianSearchBook(String searchTxt)
    {
        DatabaseAccess accessor = new DatabaseAccess();
        return accessor.LibrarianSearchBook(searchTxt);
    }

    public void updateBook(Book b)
    {
        DatabaseAccess accessor = new DatabaseAccess();
        accessor.updateBook(b);
    }

    public void insertBook(Book b)
    {
        DatabaseAccess accessor = new DatabaseAccess();
        accessor.insertBook(b);
    }

    public Book getBookDetails(string code)
    {
        DatabaseAccess da = new DatabaseAccess();
        return da.getBookDetails(code);
    }

    //checks to see if a book exists
    //Jacquie
    public Boolean bookExists(string barcode)
    { 
        Boolean exist = true;
        DatabaseAccess da = new DatabaseAccess();
        int ex = da.bookExists(barcode);
        if (ex < 1)
            exist = false;
        return exist;
    }


}
